
import static org.junit.Assert.*;
import org.junit.*;

public class ObjectFileTest {

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		ObjectFile.resetObjectFile();
		ObjectFile.startObjectFile("jUnitTest", 10, 10);
		ObjectFile.addEntry("mud", 20, "otherProgram");
		ObjectFile.addEntry("dirt", 16, "thirdProgram");
		ObjectFile.addTextRecord(24, "101010101010101010101010", "R", "+", "sand");
		ObjectFile.addTextRecord(28, "111111111111111111111111", "R", "+", "dust", "R", "+", "powder");
		ObjectFile.addTextRecord(32, "010101010101010101010101", "R", "+", "silt", "R", "+", "grains", "C", "+", "rocks");
	}
	@Test
	public void moduleNameTest(){
		String value = ObjectFile.moduleName();
		assertEquals("Should be jUnitTest", "jUnitTest", value);
	}
	@Test
	public void programLengthTest(){
		String value = ObjectFile.programLength();
		assertEquals("Should be 30", "0030", value);
	}
	@Test
	public void loadAddressTest(){
		String value = ObjectFile.loadAddress();
		assertEquals("Should be A", "000A", value);
	}
	@Test
	public void numberOfLinkingRecordsTest(){
		String value = ObjectFile.numberOfLinkingRecords();
		assertEquals("Should be 2", "0002", value);
	}
	@Test
	public void numberOfTextRecordsTest(){
		String value = ObjectFile.numberOfTextRecords();
		assertEquals("Should be 3", "0003", value);
	}
	@Test
	public void startAddressTest(){
		String value = ObjectFile.startAddress();
		assertEquals("Should be A", "000A", value);
	}
	@Test
	public void tresselTest(){
		String value = ObjectFile.tressel();
		assertEquals("Should be TRESSEL", "TRESSEL", value);
	}
	@Test
	public void versionNumberTest(){
		String value = ObjectFile.versionNumber();
		assertEquals("Should be VersionNumber", "VersionNumber", value);
	}
	@Test
	public void revisionNumberTest(){
		String value = ObjectFile.revisionNumber();
		assertEquals("Should be RevisionNumber", "RevisionNumber", value);
	}
	@Test
	public void entryNameTest1(){
		String value = ObjectFile.entryName(0);
		assertEquals("Should be mud", "mud", value);
	}
	@Test
	public void entryNameTest2(){
		String value = ObjectFile.entryName(1);
		assertEquals("Should be dirt", "dirt", value);
	}
	@Test
	public void entryLengthTest(){
		int value = ObjectFile.entryLength();
		assertEquals("Should be 2", 2, value);
	}
	@Test
	public void entryAddressTest1(){
		String value = ObjectFile.entryAddress(0);
		assertEquals("Should be 14", "0014", value);
	}
	@Test
	public void entryAddressTest2(){
		String value = ObjectFile.entryAddress(1);
		assertEquals("Should be 10", "0010", value);
	}
	@Test
	public void entryModuleNameTest1(){
		String value = ObjectFile.entryModuleName(0);
		assertEquals("Should be otherProgram", "otherProgram", value);
	}
	@Test
	public void entryModuleNameTest2(){
		String value = ObjectFile.entryModuleName(1);
		assertEquals("Should be thirdProgram", "thirdProgram", value);
	}
	@Test
	public void textRecordAddressFieldTest1() {
		String actual = ObjectFile.address(0);
		assertEquals("Should be "+Integer.toHexString(24), "0018", actual);
	}
	@Test
	public void textRecordAddressFieldTest2() {
		String actual = ObjectFile.address(1);
		assertEquals("Should be "+Integer.toHexString(28), "001C", actual);
	}
	@Test
	public void textRecordAddressFieldTest3() {
		String actual = ObjectFile.address(2);
		assertEquals("Should be "+Integer.toHexString(32), "0020", actual);
	}
	@Test
	public void textLengthTest() {
		int actual = ObjectFile.textLength();
		assertEquals("Should be 3", 3, actual);
	}
	@Test
	public void textRecordMachineCodeTest1() {
		String actual = ObjectFile.machineCode(0);
		assertEquals("Should be AAAAAA", "AAAAAA", actual);
	}
	@Test
	public void textRecordMachineCodeTest2() {
		String actual = ObjectFile.machineCode(1);
		assertEquals("Should be FFFFFF", "FFFFFF", actual);
	}
	@Test
	public void textRecordMachineCodeTest3() {
		String actual = ObjectFile.machineCode(2);
		assertEquals("Should be 555555", "555555", actual);
	}
	@Test
	public void textRecordS1RelocationCodeCodeTest1() {
		String actual = ObjectFile.relocationS1Code(0);
		assertEquals("Should be R", "R", actual);
	}
	@Test
	public void textRecordS1RelocationCodeCodeTest2() {
		String actual = ObjectFile.relocationS1Code(1);
		assertEquals("Should be R", "R", actual);
	}
	@Test
	public void textRecordS1RelocationCodeCodeTest3() {
		String actual = ObjectFile.relocationS1Code(2);
		assertEquals("Should be R", "R", actual);
	}
	@Test
	public void textRecordS2RelocationCodeCodeTest1() {
		String actual = ObjectFile.relocationS2Code(0);
		assertEquals("Should be null", null, actual);
	}
	@Test
	public void textRecordS2RelocationCodeCodeTest2() {
		String actual = ObjectFile.relocationS2Code(1);
		assertEquals("Should be R", "R", actual);
	}
	@Test
	public void textRecordS2RelocationCodeCodeTest3() {
		String actual = ObjectFile.relocationS2Code(2);
		assertEquals("Should be R", "R", actual);
	}
	@Test
	public void textRecordS3RelocationCodeCodeTest1() {
		String actual = ObjectFile.relocationS3Code(0);
		assertEquals("Should be null", null, actual);
	}
	@Test
	public void textRecordS3RelocationCodeCodeTest2() {
		String actual = ObjectFile.relocationS3Code(1);
		assertEquals("Should be null", null, actual);
	}
	@Test
	public void textRecordS3RelocationCodeCodeTest3() {
		String actual = ObjectFile.relocationS3Code(2);
		assertEquals("Should be C", "C", actual);
	}
	@Test
	public void textRecordS1ReferencedSymbolSymbolTest1() {
		String actual = ObjectFile.referencedS1Symbol(0);
		assertEquals("Should be sand", "sand", actual);
	}
	@Test
	public void textRecordS1ReferencedSymbolSymbolTest2() {
		String actual = ObjectFile.referencedS1Symbol(1);
		assertEquals("Should be dust", "dust", actual);
	}
	@Test
	public void textRecordS1ReferencedSymbolSymbolTest3() {
		String actual = ObjectFile.referencedS1Symbol(2);
		assertEquals("Should be silt", "silt", actual);
	}
	@Test
	public void textRecordS2ReferencedSymbolSymbolTest1() {
		String actual = ObjectFile.referencedS2Symbol(0);
		assertEquals("Should be null", null, actual);
	}
	@Test
	public void textRecordS2ReferencedSymbolSymbolTest2() {
		String actual = ObjectFile.referencedS2Symbol(1);
		assertEquals("Should be powder", "powder", actual);
	}
	@Test
	public void textRecordS2ReferencedSymbolSymbolTest3() {
		String actual = ObjectFile.referencedS2Symbol(2);
		assertEquals("Should be grains", "grains", actual);
	}
	@Test
	public void textRecordS3ReferencedSymbolSymbolTest1() {
		String actual = ObjectFile.referencedS3Symbol(0);
		assertEquals("Should be null", null, actual);
	}
	@Test
	public void textRecordS3ReferencedSymbolSymbolTest2() {
		String actual = ObjectFile.referencedS3Symbol(1);
		assertEquals("Should be null", null, actual);
	}
	@Test
	public void textRecordS3ReferencedSymbolSymbolTest3() {
		String actual = ObjectFile.referencedS3Symbol(2);
		assertEquals("Should be rocks", "rocks", actual);
	}
	@Test
	public void textModuleNameTest1() {
		String actual = ObjectFile.textModuleName(0);
		assertEquals("Should be jUnitTest", "jUnitTest", actual);
	}
	@Test
	public void textModuleNameTest2() {
		String actual = ObjectFile.textModuleName(1);
		assertEquals("Should be jUnitTest", "jUnitTest", actual);
	}
	@Test
	public void textModuleNameTest3() {
		String actual = ObjectFile.textModuleName(2);
		assertEquals("Should be jUnitTest", "jUnitTest", actual);
	}
	@Test
	public void totalRecordsTest() {
		String actual = ObjectFile.totalRecords();
		assertEquals("Should be 0005", "0005", actual);
	}
}
